package com.dycx.payment.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.*;

/**
 * 支付业务类型
 */
@Getter
@AllArgsConstructor
public enum PayBizTypeEnum {
    NO(0, "无"),

    PAY_VIP(1, "购买VIP"),
    ;

    private final Integer code;
    private final String name;

    public static String converter(Integer code) {
        return Arrays.stream(values()).filter(en -> en.code.equals(code)).findAny().orElse(NO).getName();
    }

    /**
     * 转为列表
     *
     * @return 枚举对象数组
     */
    public static List<Map<String, String>> getList() {
        List<Map<String, String>> list = new ArrayList<>();
        for (PayBizTypeEnum item : PayBizTypeEnum.values()) {
            Map<String, String> map = new HashMap<>();
            map.put("code", item.getCode().toString());
            map.put("name", item.getName());
            list.add(map);
        }
        return list;
    }

}
